package com.shop2cn.iapi.agentproducts.service;

import com.google.common.reflect.TypeToken;
import com.shop2cn.iapi.agentproducts.parameter.CategoryDto;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.EnvSetup;

import java.util.List;

/**
*所有商品已使用的二级类目列表Call
*FreeMaker Template自动生成代码
*/
public class SecondCategoryListCall extends YmatouBaseCall{
	private static String opurl ="product/secondCategoryList";
	
	public SecondCategoryListCall() {
		super(EnvSetup.getSystemUrl("agentproducts_iapi"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	public List<CategoryDto> getProductList(){
		String sResults=getJsonObject().get("data").getAsJsonObject().get("categoryList").getAsJsonArray().toString();
		List<CategoryDto> FreezeProductResultList=(List<CategoryDto>) FormatUtil.GSONToObject(sResults, new TypeToken<List<CategoryDto>>(){}.getType());
		return FreezeProductResultList;
	}
}